<template>
	<view class="content">
		<!-- 头部 -->
		<view class="header" style="margin-top: 50rpx;">
			<uni-nav-bar left-icon="back" left-text="返回"
			 title="我的优惠卷" color='#3b71d2' @clickLeft="back" ></uni-nav-bar>
		</view>
		<!-- 列表 -->
		<view class="list">
			<view class="li" v-for="(item,index) in list" :key='index' @tap="select_li(index)" 
			:class="current==index?'active':''">
				{{item.title}}
				<view class="row" v-show="current==index">
					
				</view>
			</view>
		</view>
		<!-- 未使用 -->
		<view class="not_used" >
			<view class="li" v-for="(item,index) in coupon_data" :style="current==2?'-webkit-filter:grayscale(100%)':''">
				<view class="left">
					<view class="top">
						{{item.coupon_name}}
					</view>
					<view class="center">
						满{{item.at_least}}元可用
					</view>
					<view class="fot" v-if="item.term_of_validity_type==0">
						有效期：{{item.start_time}}至{{item.end_time}}
					</view>
					<view class="fot" v-if="item.term_of_validity_type==1">
						领取后：{{item.fixed_term}}天内有效
					</view>
				</view>
				<view class="right">
					{{item.money}}<text style="font-size: 30rpx;">元</text>
				</view>
			</view>
		</view>
		<!-- 未使用 -->
		<!--<view class="not_used" v-show="current==2">
			<view class="li" v-for="(item,index) in 4" style="-webkit-filter:grayscale(100%)">
				<view class="left">
					<view class="top">
						满减券
					</view>
					<view class="center">
						满100元可用
					</view>
					<view class="fot">
						有效期：2019-03-20至2019-04-20
					</view>
				</view>
				<view class="right">
					20<text style="font-size: 30rpx;">元</text>
				</view>
			</view>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[
					{
						id:1,
						title:'未使用'
					},
					{
						id:2,
						title:'已使用'
					},
					{
						id:3,
						title:'已过期'
					}
				],
				current:0,
				coupon_data:[],
			}
		},
		onShow() {
			var uid=uni.getStorageSync('uid');
			this.getData({Uid:uid,type:1});
		},
		methods: {
			select_li(index){
				this.current=index;
				var uid=uni.getStorageSync('uid');
				this.getData({Uid:uid,type:index+1})
			},
			back(){
				uni.navigateBack({
					delta: 1
				})
			},
			getData(data){
				this.infoprop('/Coupon/CouponList', 'POST',data, (res) => {
					this.coupon_data=res.data.data
					console.log(this.coupon_data);
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		// 列表
		.list{
			display: flex;
			justify-content: space-around;
			margin-top: 20rpx;
			.li{
				font-size:35rpx;
				font-family:Source Han Sans CN;
				font-weight:400;
				color:rgba(153,153,153,1);
				.row{
					margin: auto;
					width:100rpx;
					height:4rpx;
					background:rgba(59,113,210,1);
					border-radius:2px;
					margin-top: 20rpx;
				}
			}
			.active{
				color:rgba(59,113,210,1);
			}
		}
	    //未使用
		.not_used{
			.li{
				margin: auto;
				width: 95%;
				height: 200rpx;
				background: url(../../static/img/6.png) no-repeat;
				background-size: 100% 100%;
				margin-top: 40rpx;
				display: flex;
				justify-content: space-between;
				.left{
					.top{
						font-size:25rpx;
						font-family:Source Han Sans CN;
						font-weight:400;
						color:rgba(255,255,255,1);
						padding-left: 10rpx;
					}
					.center{
						font-size:35rpx;
						font-family:Source Han Sans CN;
						font-weight:400;
						color:rgba(51,51,51,1);
						padding: 20rpx 10rpx;
					}
					.fot{
						font-size:25rpx;
						font-family:Source Han Sans CN;
						font-weight:400;
						color:rgba(153,153,153,1);
						padding: 5rpx 10rpx;
					}
				}
				.right{
					font-size:50rpx;
					font-family:Source Han Sans CN;
					font-weight:bold;
					color:rgba(255,255,255,1);
					padding-top: 40rpx;
					padding-right: 40rpx;
				}
			}
		}
	}

</style>
